

#include "atomic_op_asm.h"

#ifdef _ARM_ARCH_6

ENTRY_NP(_atomic_inc_64_nv)
	mov	ip, r0			/* need r0 for return value */
1:	ldrexd	r0, r1, [ip]		/* load old value */
	adds	LO, LO, #1		/* calculate new value (return value) */
	adcs	HI, HI, #0		/* fold carry into high */
	strexd	r2, r0, r1, [ip]	/* try to store */
	cmp	r2, #0			/*   succeed? */
	bne	1b			/*     no, try again? */
#ifdef _ARM_ARCH_7
	dmb
#else
	mcr	p15, 0, r2, c7, c10, 5	/* data memory barrier */
#endif
	RET				/* return new value */
END(_atomic_inc_64_nv)

STRONG_ALIAS(_atomic_inc_64,_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64_nv,_atomic_inc_64_nv)
ATOMIC_OP_ALIAS(atomic_inc_64,_atomic_inc_64)

#endif /* _ARM_ARCH_6 */
